<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/messages.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>选择房间&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</title>

<link href="${ctx}/styles/public.css" rel="stylesheet" type="text/css">
<link href="${ctx}/styles/aux_window.css" rel="stylesheet" type="text/css">
<link href="${ctx}/styles/personal.css" rel="stylesheet" type="text/css"/>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/public.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script language="JavaScript" type="text/javascript">
	var houseId = null;
	var houseNum = null;
	var customerName = null;
	function setHouseInfo(id,num){
		houseId = id;
		houseNum = num;
	}

	function reloadIframe(thiz){
		var selectId = thiz.value
		document.all.houseListFrame.src = "${ctx}/customer_chooseSingleHouseAction.do?method=chooseBuilding&selectId=" + selectId;
	}

	/**
	*保存选择的房屋到父页面。
	*/
    function saveHouseSelect(){
    	if(houseId == null || houseNum == null){
			alert("请选择一个房屋");
    		return;
    	}
    	//标识为空，则说明不需要带出业主姓名，否则要求带出业主姓名
    	var flag = "${isWithOwnerName}";
    	if(flag == null || flag == ""){
			setParentHouseInfo();
    	}else if(flag == "withOwnerName"){
	    	//获取选择房屋的客户姓名
	    	var url = "${ctx}/customer_customerAction.do?method=queryCustomerHouse";
	    	var str = "houseNumber="+houseNum;
			new Ajax.Request(url,{method: 'post', parameters: str, onComplete: setCustomerName});
		}
    }
	function setCustomerName(_response){
		var obj=eval('(' + _response.responseText + ')');
		customerName = typeof(obj.ownerName) == 'undefined'? "" : obj.ownerName;
		setParentHouseInfo();
	}

    function setParentHouseInfo(){
    	var parentFrameId = "${parentFrameId}";
    	var obj = parentFrameId != "" ? findFrame(parentFrameId) : findFrame("houseChoose");
    	if(customerName != null) obj.setHouseInfo(houseId,houseNum,customerName);
		else obj.setHouseInfo(houseId,houseNum);

        windowClose();
    }


</script>
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td>
        	<span class="window_head_intext">
        		<img src="${ctx}/images/ico_Advance.gif" align="absmiddle">&nbsp;选择房间
        	</span>
        </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td class="content">
    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="24"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td>&nbsp;&nbsp;楼栋单元：
              <pms:unitedSelect name="selectMenu"
              					dataList="${buildings}"
              					optionLabel="selectText"
              					optionValue="selectId"
              					onChange="reloadIframe(this);"
              					selectText="请选择...">
              </pms:unitedSelect>
                </td>
                <td>&nbsp;</td>
            </tr>
          </table></td>
        </tr>
	  		<tr>
        		<td class="aux_outtable_color">
        			<iframe id="houseListFrame" name="houseListFrame" src="${ctx}/customer_chooseSingleHouseAction.do?method=initHouseList" frameborder="0" height="305" width="100%" scrolling="no" ></iframe>
        		</td>
	  		</tr>
    	</table>
    </td>
  </tr>
  <tr>
    <td colspan="2" class="window_footer">
    <table border="0" cellspacing="0" cellpadding="0">
        <tr>
		  <td>
		  	<table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td class="buttonOffLeft" id="btn1_21"></td>
                <td class="buttonOffMiddle" id="btn1_22" onClick="saveHouseSelect();" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onBlur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom">确定</td>
                <td class="buttonOffRight" id="btn1_23"></td>
              </tr>
          	</table>
          </td>
          <td class="btn_between_space"></td>
          <td>
          	<table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td class="buttonOffLeft" id="btn1_31"></td>
                <td class="buttonOffMiddle" id="btn1_32" onClick="windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onBlur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom">关闭</td>
                <td class="buttonOffRight" id="btn1_33"></td>
              </tr>
          	</table>
          </td>
        </tr>
      </table>
      <p>&nbsp;</p></td>
  </tr>
</table>
</body>
</html>